package com.uatair.common.mqtt.domain;

import com.uatair.common.utils.DateUtils;
import lombok.Data;

import java.util.Date;

@Data
public class WuHuFlightData {
    private String orderID;
    private String manufactureID;
    private String uasID;
    private long flightTime; // 累计飞行时长(秒)
    private String timeStamp; // 累计飞行时长(秒)
    private int interval;    // 本次消息间隔时间(秒)
    private String coordinate;
    private long longitude;
    private long latitude;
    private long height;
    private long altitude;
    private long speed;
    private String course;
    private String uavType;
    private double loadWeight;
    private String industryAttribute;

    // getters and setters

    public String toJson() {
        return String.format(
                "{\"OrderID\":\"%s\",\"ManufactureID\":\"%s\",\"UASID\":\"%s\"," +
                        "\"TimeStamp\":\"%s\",\"FlightTime\":%d,\"Coordinate\":\"%s\"," +
                        "\"Longitude\":%d,\"Latitude\":%d,\"Height\":%d,\"Altitude\":%d," +
                        "\"GS\":%d,\"Course\":\"%s\",\"UavType\":\"%s\"," +
                        "\"Loadweight\":%.2f,\"IndustryAttribute\":\"%s\"}",
                orderID, manufactureID, uasID,
                timeStamp, flightTime, coordinate,
                longitude, latitude, height, altitude,
                speed, course, uavType,
                loadWeight, industryAttribute
        );
    }

    /*// 基础信息
    private String sn;                // 飞机序列号
    private String orderId;           // 飞行记录编号
    private String manufactureId;      // 制造商代码

    // 时间相关
    private long flightTime;          // 累计飞行时长(秒)
    private long startTime;           // 飞行开始时间戳(ms)
    private long lastUpdateTime;      // 最后更新时间戳(ms)
    private long timeStamp;      // 最后更新时间戳(ms)

    // 位置信息
    private double longitude;
    private double latitude;
    private double height;
    private double altitude = -999;

    // 动态信息
    private double speed;
    private String course = "COURSE-DEFAULT";

    // 设备信息
    private String uavType;
    private double loadWeight;
    private String industryAttribute;

    // 其他元数据
    private String uasId = "UAS-DEFAULT";
    private String coordinate = "2";

    *//**
     * 获取本次实际间隔时间(秒)
     *//*
    public long getActualInterval() {
        if (lastUpdateTime == 0 || startTime == 0) return 0;
        return (lastUpdateTime - startTime) / 1000;
    }

    *//**
     * 获取格式化时间戳(YYYYMMDDHHmmss)
     *//*
    public String getFormattedTimestamp() {
        return DateUtils.parseDateToStr("yyyyMMddHHmmss", new Date(lastUpdateTime));
    }*/
}